package com.geek.javase.ch16.work.work1;

/*
 *@author wangpeng
 *2025/11/2
 *@description TODO
 */
public class JoinTest {
    public static void main(String[] args) throws InterruptedException {
        // 创建线程2 - 打印B
        Thread thread2 = new Thread(() -> {
            System.out.println("B");
        });

        // 创建线程1 - 打印A和C
        Thread thread1 = new Thread(() -> {
            System.out.println("A");

            try {
                // 等待线程2执行完成（打印B）
                thread2.join();
                System.out.println("C");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });

        // 启动线程
        thread1.start();
        thread2.start();
    }
}